﻿@model ExplorerVM
@using System.Web.Mvc.Html
@using nanoCMS.Core
@using nanoCMS.Core.WebProviders.HtmlHelpers
@using nanoCMS.Core.WebProviders.HtmlHelpers.Pagination
@using nanoCMS.Forum.Config
@using nanoCMS.Forum.Resources
@using nanoCMS.Forum.WebUI.Models.ViewModels
@*

<div>@Html.ActionLink("up", "Index", "Forum", new { forumID = Model.Forum.ParentForumID}, null)</div>
<div>ovaj forum: @Model.Forum.Title</div>
<div>@Html.ActionLink("Create thread", "CreateThread", "Forum", new { forumID = Model.Forum.ForumID }, null)</div>
<div>--------------subforums:</div>
@foreach (var subForum in Model.Forum.SubForums)
{
    <div>@Html.ActionLink(@subForum.Title, "Index", "Forum", new { forumID = subForum.ForumID}, null)</div>
    <div>post count: @subForum.PostsCount | thread count @subForum.ThreadsCount</div>
    <div>
        @Html.ActionLink("Edit", "Index", "ForumAdmin", new { forumID = @subForum.ForumID }, new { @class = "modal" })
        @Html.ActionLink("Delete", "DeleteForum", "Forum", new { forumID = @subForum.ForumID }, null)
        
     </div>
}
<div>--------------threads:</div> 
@foreach (var thread in Model.Threads)
{
    <div>@Html.ActionLink(@thread.Title, "ShowThread", "Forum", new { threadID = thread.ThreadID }, null)
        post count (@thread.PostsCount) views count (@thread.ViewsCount)
        
        @Html.ActionLink("Move", "MoveThread", "ForumAdmin", new { threadID = @thread.ThreadID }, new { @class = "modal" })
    </div>
}

@{
    PagerOptions pagerOptions = new PagerOptions()
    {
        PageIndexParameterName = "Page"
    };
}
@Html.Pager(Model.Forum.ThreadsCount, ForumConfig.ThreadsPerPage, Model.Page, "Index", "Forum", 
    pagerOptions, "ForumDefault", new { }, null)

*@
<article class="article">
    <header class="page-title">
        @if (Model.Forum.ParentForumID > 0)
        {
            <p>@Html.LinkInner("Up", new {forumID = Model.Forum.ParentForumID, elementKey = ViewBag.ElementKey, action = "Index"}, null)</p>
        }
        <h2>
            Forum
            @if (SessionManagerBase.IsAdmin)
            {
                <span>(@Html.ActionLink("Admin", "Index", "ForumAdmin", null, new { @class = "modal" }))</span> 
            }</h2>
    </header>
    <!-- end page title -->
    <table class="forum">
        <tr>
            <th colspan="3">@Model.Forum.Title - @Translation.SubForums
            </th>
        </tr>
        <tr class="head">
            <td width="70%">
                @Translation.Forum
            </td>
            <td width="10%">
                @Translation.NumberOfThreads
            </td>
            <td width="14%">
                @Translation.NumberOfPosts
            </td>
        </tr>
        @foreach (var subForum in Model.Forum.SubForums)
        {

            <tr>
                <td>
                    @Html.LinkInner(subForum.Title, new { forumID = subForum.ForumID, elementKey = ViewBag.ElementKey, action = "Index" }, null)
                    @if (SessionManagerBase.IsAdmin)
                    {
                        <p>
                            (
                            @Html.ActionLink(Translation.Edit, "Index", "ForumAdmin", new { forumID = @subForum.ForumID }, new { @class = "modal" })
                            @Html.ActionLink(Translation.Delete, "DeleteForum", "Forum", new { forumID = @subForum.ForumID }, null)
                            )</p>
                    }
                </td>
                <td>
                    @subForum.ThreadsCount
                </td>
                <td>
                   @subForum.PostsCount
                </td>
            </tr>

        }
    </table>
    <div class="separator">
    </div>
    @if (SessionManagerBase.IsAuthenticated)
    {
        @Html.LinkInner(Translation.CreateThread, new { action = "CreateThread", forumID = Model.Forum.ForumID, elementKey = ViewBag.ElementKey }, null)
    }
    <table class="forum">
        <tr>
            <th colspan="3">@Model.Forum.Title - @Translation.Threads
            </th>
        </tr>
        <tr class="head">
            <td width="70%">
                @Translation.Thread
            </td>
            <td width="10%">
                @Translation.Info
            </td>
            <td width="14%">
                @Translation.LastPost
            </td>
        </tr>
        @foreach (var thread in Model.Threads)
        {

            <tr>
                <td>@Html.LinkInner(thread.Title, new { threadID = thread.ThreadID, elementKey = ViewBag.ElementKey, action = "ShowThread" }, null)
                    @if (SessionManagerBase.IsAdmin)
                    {
                        <p>
                            (
                            @Html.ActionLink(Translation.Delete, "DeleteThread", "Forum", new { threadID = thread.ThreadID, forumID = Model.Forum.ForumID }, null)
                            @Html.LinkInner(Translation.Edit, new { threadID = thread.ThreadID, elementKey = ViewBag.ElementKey, action = "EditThread"}, null) 
@*                            @Html.ActionLink("Edit", "EditThread", "Forum", new { threadID = thread.ThreadID }, null)*@
                            @Html.ActionLink(Translation.Move, "MoveThread", "ForumAdmin", new { threadID = @thread.ThreadID }, new { @class = "modal" })
                            )</p>
                    }
                </td>
                <td>
                    @Translation.NoViews: @thread.ViewsCount
                    <br />
                    @Translation.NoOpens: @thread.PostsCount
                </td>
                <td>
                    @if (@thread.LastPostId > 0)
                    {
                        <i>U @thread.LastPostTime, od @thread.LastPostUser</i> 
                    }
                    else
                    {
                        @:---
                                                 }
                </td>
            </tr>

        }
    </table>
    @Html.Pager(Model.Forum.ThreadsCount, ForumConfig.ThreadsPerPage, Model.Page,
    new PagerOptions(), new { action = "Index", elementKey = ViewBag.ElementKey, forumID = Model.Forum.ForumID })
</article><!-- end #article -->